<template>
  <div style="background: #fff">
    <div class="title">
      <div>{{ title }}</div>
    </div>
    <el-row>
      
      
        <div
          class="grid-content bg-purple-light"
          style="border-bottom: 1px solid #ccc"
        >
          <el-form label-width="120px">
            <el-form-item label="标题">
              <el-input v-model="item.name" autocomplete="off"></el-input>
            </el-form-item>
            
             <el-form-item label="图文">
                <div id="editor"></div>
            </el-form-item>
            
            
          </el-form>
        </div>
      
    </el-row>

    <div class="content">
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="edit">确 定</el-button>
      </div>
    </div>

    
  </div>
</template>

<script>
import mixin from "../../js/mixin";
import E from "wangeditor";
export default {
  name: "homePage",
  mixins: [mixin],
  data() {
    return {
      is_page: false,
      api_url: "article",
      query: {
        p_id: 0,
      },
      item: {  },
    };
  },
  components: {},
  mounted() {},
  created() {
    this.init();
  },
  methods: {
    init() {
      let id = this.$route.params.id;
      if (id != "-1") {
        this.item.id = id;
        this.getItem();
      } else {
         let that = this;
          var editor = new E("#editor");
          setTimeout(function () {
            that.showWangEdit(editor);
          }, 500);
      }
      this.title = this.$route.meta.title;
      
    },
    getItem() {
      this.global
        .httpRequest(this.api_url, {
          id: this.item.id,
        })
        .then((res) => {
          this.item = res;
          
           let that = this;
          var editor = new E("#editor");
          setTimeout(function () {
            that.showWangEdit(editor);
          }, 500);
        });
    },
  },
};
</script>

